<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@include file="/WEB-INF/webpage/common/taglibs.jspf"%>
<%@taglib prefix="spring" uri="http://www.springframework.org/tags" %>


<!DOCTYPE html>
<html lang="en">

<head>
    <title><spring:message code="sys.site.title" arguments="${platformName}"/></title>
    <meta name="keywords" content="<spring:message code="sys.site.keywords" arguments="${platformName}"/>">
    <meta name="description" content="<spring:message code="sys.site.description" arguments="${platformName}"/>">

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="cache-control" content="no-cache">
	<link rel="shortcut icon" href="${staticPath}/common/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" type="text/css" href="${staticPath}/uadmin/css/login.css"/>

	    <link rel="stylesheet" type="text/css"
		href="${staticPath}/login/css/style.css" />
	    <style type="text/css">

	        .password-eye-my {
	        	position: absolute;
	    		top: 8px;
	    		right: 25px;
	            z-index: 999;
	            display: block;
	            width: 26px;
	            height: 26px;
	            line-height: 34px;
	            text-align: center;
	            pointer-events: auto;
	            cursor: pointer;
	            background-image: url('${staticPath}/login/images/no_eye.png');
	            background-size: 26px;
	            background-repeat: no-repeat;
	        }

	        .password-eye-my.close {
	            background-image: url('${staticPath}/login/images/eye-close.png');
	        }
	        input[type="password"]::-ms-reveal{
	            display: none;
	        }
	        input[type="password"]::-ms-clear{
	            display: none;
	        }
	        input[type="password"]::-o-clear{
	            display: none;
	        }
	    </style>
</head>
<body>

<div id="main-center">
	<div class="w-1200">
		<form  id="loginform" action="${ssoServerLoginUrl}" method="post" onsubmit="return check();">
		<input type="hidden" name="loginType" id="loginType" value="true" />
			<div class="box form">
				<div class="user-in">
					<a href="javascript:" class="QR-icon"></a>
					<div class="QR" style="display: none;">
						<div class="qr-t">
							APP下载
							<p>扫描下面二维码下载APP</p>
						</div>
						<div class="qr-img">
							<div class="imgbox">
								<img id="ios-img" src="${staticPath}/uadmin/images/login/ios.png"  onerror="this.src='${staticPath}/common/img/default_load.jpg'"/>
								<p>苹果版 v1.0</p>
							</div>
							<div class="imgbox">
								<img id="android-img" src="${staticPath}/uadmin/images/login/android.png" onerror="this.src='${staticPath}/common/img/default_load.jpg'"/>
								<p>安卓版 v1.0</p>
							</div>
						</div>
					</div>
					<div class="pwdLogin">
						<input type="hidden" name="redirectUrl" value="${ssoClientUrl}">
						<div class="t"><spring:message code="sys.login.title"/></div>
						<div class="in"><input name="username" id="username" class="form-control" placeholder="<spring:message code="sys.login.username.placeholder"/>" required=""></div>
						<div class="in">
							<input name="password" id="password" type="password" class="form-control" placeholder="<spring:message code="sys.login.password.placeholder"/>" required="">
							<span class="password-eye-my" title="显示密码" onclick="showPwd(this,'password')"></span>
							<div class="auto">
								<input id="rememberMe"  type="checkbox" name="rememberMe" value="1" class="i-checks">
								<spring:message code="sys.login.rememberMe"/>
							</div>
						</div>
						<c:if test="${showCaptcha eq 1}">
							<div class="form-group">
								<div class="pull-left" style="margin-left: 20px;padding-left:0;width: 40% ">
									<input name="jcaptchaCode" class="form-control" placeholder="<spring:message code="sys.login.captcha.placeholder"/>" required="">
									<input name="rememberMe" maxlength="5" value="0" type="hidden">
								</div>
								<div class="pull-right">
									<img id="img_jcaptcha"  src="${appPath}/jcaptcha.jpg" width="120" height="35" onclick="changeJcaptchaSrc();" />
								</div>
							</div>
							<div class="clearfix"></div>
						</c:if>
						<div class="sub">
							<button type="submit" class="btn btn-success btn-block"><spring:message code="sys.login.submit.label"/> </button>
						</div>
						<div class="error">${error}</div>
					</div>
				</div>
			</div>
		</form>
	</div>
</div>
<div id="light"></div>
<div id="light2"></div>
<%-- <script src="${staticPath}/vendors/jquery/js/jquery.min.js"></script>
<script src="${staticPath}/vendors/bootstrap/js/bootstrap.min.js"></script>
<script src="${staticPath}/vendors/bootstrapvalidator/js/bootstrapValidator.js"></script> --%>

		<script src="${staticPath}/vendors/jquery/js/jquery-1.11.0.min.js"></script>
<%--		<script src="${staticPath}/vendors/jquery/js/jquery.base64.js"></script>--%>
		<script src="${staticPath}/vendors/base64/js/base64.js"></script>
<%--		<script src="${staticPath}/vendors/jsencrypt/js/jsencrypt.js"></script>--%>
	<%-- <script src="${staticPath}/m/Base64.js"></script> --%>
<script type="text/javascript">
	$(document).ready(function () {
		//$("#loginform").bootstrapValidator(); //<!-- 跨站脚本攻击过滤器 -->
		var error = "${error}";
		if (error != "") {
			showToast(error, "error");
			setTimeout(function () {
				window.location.replace("${appPath}/admin/login")
			}, 1000)

		}
	});

	function showToast(msg, shortCutFunction) {
		toastr.options = {
			"closeButton": true,
			"debug": false,
			"progressBar": true,
			"positionClass": "toast-bottom-right",
			"onclick": null,
			"showDuration": "400",
			"hideDuration": "1000",
			"timeOut": "7000",
			"extendedTimeOut": "1000",
			"showEasing": "swing",
			"hideEasing": "linear",
			"showMethod": "fadeIn",
			"hideMethod": "fadeOut"
		}
		toastr[shortCutFunction](msg, "提示");
	}

    function changeJcaptchaSrc(){
		document.getElementById("img_jcaptcha").src='${appPath}/jcaptcha.jpg?_='+(new Date()).getTime();
	}
    window.onload = function(){
	    getIOSandAND();
		var qr = document.getElementsByClassName("QR")[0];
		var pwdLogin = document.getElementsByClassName("pwdLogin")[0];
		var qrClick =  document.getElementsByClassName("QR-icon")[0];
		qrClick.onclick = function(){
			if(qr.style.display === "none"){
				//切换APP下载页面
				this.className +=" active";
				pwdLogin.style.display = "none";
				qr.style.display = "block";
			}else{
				//切换登录页面
				this.className = "QR-icon";
				pwdLogin.style.display = "block";
				qr.style.display = "none";
			}
		}
	}
	function getIOSandAND(){
		 $.ajax({
			type:"POST",
			url:"${adminPath}/sys/appversion/findAppVersion",
			async:false,
			success:function(data){
				data = data;
				$.each(data,function(i,item){
					if(item.type==2){
						$("img#ios-img").attr("src","${appPath}/"+item.qrcodeUrl);
					}else{
						$("img#android-img").attr("src","${appPath}/"+item.qrcodeUrl);
					}
				});

			}
		 });
	 }


	function check() {
		// var username = document.getElementById("username");
		// usernameStr = $.base64.encode(username.value);
		// username.value =usernameStr;
		// var password = document.getElementById("password");
		// var encodeStr = ($.base64.encode(password.value));
		// password.value = encodeStr;

		var password = $("#password").val();

		var username = $("#username").val();
		var encodeStr = Base64.encode(password);
		$("#password").val(encodeStr);
		$("#username").val(Base64.encode(username));
		return true;
	}
    function showPwd(obj, id) {
        if ($(obj).hasClass("close")) {
            $(obj).removeClass('close').attr('title', '显示密码');
        } else {
            $(obj).addClass('close').attr('title', '隐藏密码');
        }
        var password = document.getElementById(id);
        if (password.type == "password") {
            password.type = "text";
        } else {
            password.type = "password";
        }
    }
</script>
</body>
</html>
